<template>
	<view class="navList" v-if="list.length > 0">
		<view class="navList-li" v-for="(item, index) of list" :key="index">
			<view class="navList-li-top flex">
				<image class="navList-li-top-img" src="https://www.zzzsyh.com/applets/agent/agent/house.png" mode=""></image>
				<text class="navList-li-top-txt font_blod">生产厂商：{{item.factoryName}}</text>
			</view>
			<view class="navList-li-content">
				<view class="navList-li-content-left">
					<image v-if="item.factoryImages" class="navList-li-content-left-img" :src=item.factoryImages mode=""></image>
					<image v-else class="navList-li-content-left-img" src='https://www.zzzsyh.com/applets/agent/agent/shop.png' mode=""></image>
				</view>
				<view class="navList-li-content-right">
					<view class="navList-li-content-right-top">
						优选厂家
					</view>
					<view class="navList-li-content-right-bottom" v-if="item.factoryProducts">
						合作产品：{{item.factoryProducts}}
					</view>
				</view>
			</view>
			<view class="navList-li-btn">
				<!-- <view class="navList-li-btn-phone" @click="cli_playPhone(item.factoryPhone)">
					<image class="navList-li-btn-phone-img" src="https://www.zzzsyh.com/applets/agent/agent/phone.png" mode=""></image>
					<text class="navList-li-btn-phone-txt">拨打电话</text>
				</view> -->
				<view class="navList-li-btn-yd font_blod" @click="cli_ljyd(item, index)">
					立即预订
				</view>
			</view>
		</view>
	</view>
	<view class="allno" v-else>
		<view class="yPopNone">
			<image class="yPopNoneImg" src="https://www.zzzsyh.com/applets/agent/factory/23.png" mode="">
			</image>
			<view class="yPopNoneTxt">
				暂无相关厂家~
			</view>
		</view>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				id: '',
				list: []
			}
		},
		onLoad(msg) {
			this.id = msg.id
		},
		mounted() {
			this.getFactoryByTypeId(this.id)
		},
		methods: {
			// 拨打电话
			cli_playPhone (val) {
				uni.makePhoneCall({
				    phoneNumber: val //仅为示例
				});
			},
			// 点击立即预订
			cli_ljyd (item, index) {
				console.log(item);
				uni.setStorageSync('factoryId', item.id)
				// uni.setStorageSync('factoryName', item.factoryName)
				// uni.setStorageSync('factoryPhone', item.factoryPhone)
				
				uni.navigateTo({
					url:'/pages/yuDing/yuDing?'
				})
			},
			// 获取列表
			getFactoryByTypeId (typeId) {
				uni.request({
					url: allapi.getFactoryByTypeId,
					data: {
						typeId: typeId
					},
					success: (res) => {
						console.log(res);
						this.list = res.data.data
					}
				})
			}
		}
	}
</script>

<style scoped>
	.flex {
		display: flex;
		align-items: center;
	}
	.allno {
		position: absolute;
		width: 100%;
		height: 100%;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.navList-li {
		margin: 16rpx 24rpx 0;
		min-height: 306rpx;
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 24rpx;
		box-sizing: border-box;
	}

	.navList-li-top {
		margin-top: 28rpx;
	}

	.navList-li-top-img {
		width: 42rpx;
		height: 42rpx;
	}

	.navList-li-top-txt {
		margin-left: 8rpx;
		font-size: 32rpx;
		color: #333333;
	}
	.navList-li-content {
		min-height: 96rpx;
		margin-top: 24rpx;
		display: flex;
	}
	.navList-li-content-left-img {
		width: 96rpx;
		height: 96rpx;
		background: #EEEEEE;
		border-radius: 50%;
	}

	.navList-li-content-right {
		height: 100%;
		margin-left: 16rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.navList-li-content-right-top {
		height: 40rpx;
		line-height: 40rpx;
		font-size: 28rpx;
		color: #333333;
		font-weight: 400;
	}

	.navList-li-content-right-bottom {
		/* height: 34rpx; */
		line-height: 34rpx;
		font-size: 24rpx;
		color: #666666;
		font-weight: 400;
		margin-bottom: 6rpx;
		margin-top: 12rpx;
	}
	.navList-li-btn {
		display: flex;
		justify-content: flex-end;
		align-items: center;
		margin-top: 10rpx;
	}
	.navList-li-btn-phone {
		width: 184rpx;
		height: 64rpx;
		border-radius: 34rpx;
		border: 2rpx solid #333333;
		display: flex;
		align-items: center;
		margin-right: 24rpx;
	}
	.navList-li-btn-phone-img {
		width: 32rpx;
		height: 32rpx;
		margin-left: 26rpx;
	}
	.navList-li-btn-phone-txt {
		font-size: 24rpx;
		color: #333333;
		margin-left: 8rpx;
	}
	.navList-li-btn-yd {
		width: 168rpx;
		height: 68rpx;
		line-height: 68rpx;
		background: linear-gradient(90deg, #2ACE52 0%, #1DC248 100%);
		border-radius: 34rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		text-align: center;
	}
</style>
